/**
 * Copyright � 2012 GestureSoft. ALL RIGHTS RESERVED.
 * This file contains proprietary and GestureSoft CONFIDENTIAL Information.
 * Use, disclosure or reproduction is prohibited.
 * 
 * @fileName ThemeParser.as
 * @creationDate Aug 8, 2012
 * @author 
 * @version 1.0
 */
package com.gesturesoft.imultimax.model.thememanger.xmlparser
{
	import com.gesturesoft.imultimax.model.vo.ThemeDetailVO;
	import com.gesturesoft.imultimax.model.vo.ThemeVO;
	import com.gesturesoft.imultimax.model.vo.ThemeVO1;
	
	import mx.collections.ArrayCollection;

	public class ThemeParser
	{
		
		public static function parse(themes:XML):ArrayCollection
		{
			
			var arrThemes:ArrayCollection = new ArrayCollection();
			
			for each(var theme:XML in themes.theme)
			{
				
				var arrThemeDetailVO:ArrayCollection = new ArrayCollection();
				var themeVO:ThemeVO = new ThemeVO();
				var themeDetailVO:ThemeDetailVO = new ThemeDetailVO();
				
				themeVO.name = theme.@name.toString();
				themeVO.active = theme.@active.toString();
				themeVO.creator = "admin";
				
				//Getting primary color details
				for each(var primaryDetail:XML in theme.primaryColor)
				{
					
					var primaryColorDetailVO:ThemeDetailVO = new ThemeDetailVO();
					primaryColorDetailVO.propertyName = "primary_color";
					primaryColorDetailVO.gradient1 = primaryDetail.gradient1.toString();
					primaryColorDetailVO.gradient2 = primaryDetail.gradient2.toString();
					primaryColorDetailVO.stroke = primaryDetail.stroke.toString();
					primaryColorDetailVO.values = primaryDetail.values.toString();
					primaryColorDetailVO.textColor = primaryDetail.textColor.toString();
					
					arrThemeDetailVO.addItem(primaryColorDetailVO);
				}
				
				//Getting secondary color details
				for each(var secondaryDetail:XML in theme.secondaryColor)
				{
					
					var secondaryColorDetailVO:ThemeDetailVO = new ThemeDetailVO();
					secondaryColorDetailVO.propertyName = "secondary_color";
					secondaryColorDetailVO.gradient1 = secondaryDetail.gradient1.toString();
					secondaryColorDetailVO.gradient2 = secondaryDetail.gradient2.toString();
					secondaryColorDetailVO.stroke = secondaryDetail.stroke.toString();
					secondaryColorDetailVO.values = secondaryDetail.values.toString();
					secondaryColorDetailVO.textColor = secondaryDetail.textColor.toString();
					
					arrThemeDetailVO.addItem(secondaryColorDetailVO);
				}
				
				trace(theme.bgImage.toString())
				for each(var imageDetail:XML in theme.bgImage)
				{
					
					var bgImageDetailVO:ThemeDetailVO = new ThemeDetailVO();
					bgImageDetailVO.propertyName = "bgImage";
					bgImageDetailVO.values = imageDetail.toString();
					
					arrThemeDetailVO.addItem(bgImageDetailVO);
					
				}
				
				themeVO.arrThemeDetailVO = arrThemeDetailVO;
				arrThemes.addItem(themeVO);
				
			}
			
			return arrThemes;
		}
	}
}